package com.example.hcbmsm.controller;

import com.example.hcbmsm.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Map;

/**
 * @author Xinghm
 * @version 1.0
 * @since 2024/10/29 17:59
 */
@RestController
@CrossOrigin
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private LoginService loginService;

    @PostMapping("/patient")
    public Map patientLogin(String patientUsername, String patientPassword) {
        return loginService.patientLogin(patientUsername, patientPassword);
    }

    @PostMapping("/checkPatient")
    public Map checkPatient(String token) {
        return loginService.checkPatient(token);
    }

    @PostMapping("/doctor")
    public Map doctorLogin(String doctorUsername, String doctorPassword) {
        return loginService.doctorLogin(doctorUsername, doctorPassword);
    }

    @PostMapping("/checkDoctor")
    public Map checkDoctor(String token) {
        return loginService.checkDoctor(token);
    }

    @PostMapping("/admin")
    public Map adminLogin(String adminUsername, String adminPassword) {
        return loginService.adminLogin(adminUsername, adminPassword);
    }

    @PostMapping("/checkAdmin")
    public Map checkAdmin(String token) {
        return loginService.checkAdmin(token);
    }
}
